import java.util.*;
/*给你一个二元数组 nums ，和一个整数 goal ，请你统计并返回有多少个和为 goal 的 非空 子数组。
子数组 是数组的一段连续部分。
输入：nums = [1,0,1,0,1], goal = 2
输出：4
*/
public class Text {
    public static int check(int[] nums, int goal) {
        int n = nums.length;
        int[] arr = new int[n + 1];
        for (int i = 0; i < n; i++) {
            arr[i + 1] = arr[i] + nums[i];
        }
        Map<Integer, Integer> map = new HashMap<>();
        int count = 0;
        for (int i = 0; i <= n; i++) {
            if (map.containsKey(arr[i] - goal)) {
                count += map.get(arr[i] - goal);
            }
            map.put(arr[i], map.getOrDefault(arr[i], 0) + 1);
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        int goal = sc.nextInt();
        int countg = check(nums, goal);
        System.out.println(countg);
    }
}